import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';

import { TransactionService } from '../../../services/transaction.service';
import { aroAnimation } from '../../../animation';

@Component({
  selector: 'app-bookcaselist',
  templateUrl: './bookcaselist.component.html',
  styleUrls: ['./bookcaselist.component.css'],
  animations: [aroAnimation]
})
export class BookcaselistComponent implements OnInit {

  public readerId: string = localStorage.getItem('ReaderId');

  public borrowRecords: Array<any> = [];

  constructor(private location: Location, private currentRouter: ActivatedRoute, private router: Router,
    private transactionService: TransactionService
  ) { }

  ngOnInit() {
    if (this.readerId) {
      this.transactionService.getBorrowRecords(this.readerId).subscribe(res => {
        console.log(res);
        this.borrowRecords = res.Data;
      });
    }
  }

  public goBack_onclick(): void {
    this.location.back();
  }

  public goLogin_onclick(): void {
    this.router.navigate(['./login']);
  }

}
